#include <iostream>

#include "./Logger.h"
#include "./Timestamp.h"

Logger &Logger::getInstance()
{
    static Logger logger{};
    return logger;
}

void Logger::setLogLevel(const LogLevel logLevel)
{
    this->logLevel_ = logLevel;
}

// [级别信息] timestamp : msg
void Logger::log(const std::string msg)
{
    std::string logLevel{""};
    switch (this->logLevel_)
    {
    case LogLevel::INFO:
        logLevel = "[INFO]";
        break;
    case LogLevel::ERROR:
        logLevel = "[ERROR]";
        break;
    case LogLevel::FATAL:
        logLevel = "[FATAL]";
        break;
    case LogLevel::DEBUG:
        logLevel = "[DEBUG]";
        break;
    default:
        break;
    }

    std::cout << logLevel << " " << Timestamp::now().toString() << " : " << msg << std::endl;
}